package com.matt.foundation.query;

import com.matt.commons.exception.BusinessException;

import com.matt.commons.model.ErrorCode;
import com.matt.commons.page.PagerQuery;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.apache.commons.lang.StringUtils;

@Data
@ToString(callSuper=true)
@EqualsAndHashCode(callSuper=true)
public class ChildrenQuery extends PagerQuery {

    private String childrenId;

    private String name;

    private String areaId;

    private String className;

    private String classId;

    private Boolean active;

    private String code;

    /********** add by lch *******/
    //班级类型 0 :托班+早教  1：托班  2：早教
    private Integer category=0;

    //孩子的状态 0:未生效, 1:正常，2 合同结束, 3:已退学，4:已毕学
    private Integer status;


    //托班状态 0:（已结束）所有托班课程结束， 1（进行中） 至少一个托班合同未结束
    private Integer nurseryStatus;

    //早教状态 0：已结束  1：进行中
    private Integer earlyStatus;



    private String orderBy;

    private String sequence;

    public void validateOrderByAndSequence(){

        if( (StringUtils.isNotBlank(getOrderBy())
                && !"createTime".equalsIgnoreCase(getOrderBy())
                && !"status".equalsIgnoreCase(getOrderBy())
                && !"category".equalsIgnoreCase(getOrderBy())
                && !"nurseryStatus".equalsIgnoreCase(getOrderBy())
                && !"times".equalsIgnoreCase(getOrderBy())
                && !"lastEvaluated".equalsIgnoreCase(getOrderBy())
                && !"gender".equalsIgnoreCase(getOrderBy())
        )
                || (StringUtils.isNotBlank(getSequence()) && !"desc".equalsIgnoreCase(getSequence()) && !"asc".equalsIgnoreCase(getSequence())) ){
            throw new BusinessException(ErrorCode.UNDEFINED, "参数错误");
        }

    }



}